package java_test.collection;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class TestColl {
    public static void main(String[] args) {
        List<String> list = new ArrayList<String>();
        list.add("Hello");
        list.add("world");
        list.add("1234567890");
        // forEach
//        for (String item:list)
//            System.out.println(item);
//        for (int i=0;i<list.size();i++)
//            System.out.println(list.get(i));

        String[] strArray = new String[list.size()];
        list.toArray(strArray);
//        for (String item: strArray)
//            System.out.println(item);
//        for (int i=0;i<strArray.length;i++)
//            System.out.println(strArray[i]);

        Iterator<String> ite = list.iterator();
        while (ite.hasNext())//判断下一个元素之后有值
        {
            System.out.println(ite.next());
        }

    }
}
